package com.eshop.product.mapper;

import com.eshop.product.model.ProductSpecification;
import org.apache.ibatis.annotations.*;

/**
 * @ClassName CategoryMapper
 * @Description
 * @Author 47980
 * @Date 2020/5/17 16:08
 * @Version V_1.0
 **/
@Mapper
public interface ProductSpecificationMapper {

    @Insert("INSERT INTO product_specification(name,value,product_id) VALUES(#{name},#{value},#{productId})")
    public void add(ProductSpecification productSpecification);

    @Update("UPDATE product_specification SET name=#{name},value=#{value},product_id=#{productId} WHERE id=#{id}")
    public void update(ProductSpecification productSpecification);

    @Delete("DELETE FROM product_specification WHERE id=#{id}")
    public void delete(Long id);

    @Select("SELECT * FROM product_specification where id=#{id}")
    @Results({
        @Result(column = "product_id", property = "productId")
    })
    public ProductSpecification findById(Long id);

    @Select("SELECT * FROM product_specification where product_id=#{productId}")
    @Results({
            @Result(column = "product_id", property = "productId")
    })
    public ProductSpecification findByProductId(Long productId);
}
